{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<Trigger @onError={{action this.onError}} @do={{this.fetchParent}} as |trigger|>
  {{did-insert trigger.fns.do}}
  {{#if trigger.data.isBusy}}
    <li>
      <a href="#" aria-label="loading" data-test-breadcrumb="loading">
        …
      </a>
    </li>
  {{/if}}
  {{#if trigger.data.isSuccess}}
    {{#if (and trigger.data.result this.hasParent)}}
      <li>
        <LinkTo
          @route="jobs.job.index"
          @model={{trigger.data.result}}
          data-test-breadcrumb={{"jobs.job.index"}}
        >
          <dl>
            <dt>
              Parent Job
            </dt>
            <dd>
              {{trigger.data.result.trimmedName}}
            </dd>
          </dl>
        </LinkTo>
      </li>
    {{/if}}
    <li
      {{(modifier
        this.maybeKeyboardShortcut
        label="Go up a level"
        pattern=(array "u")
        menuLevel=true
        action=(action this.traverseUpALevel (array "jobs.job" this.job.idWithNamespace))
        exclusive=true
      )}}
    >
      <LinkTo
        @route="jobs.job.index"
        @model={{this.job}}
        data-test-breadcrumb={{"jobs.job.index"}}
        data-test-job-breadcrumb
      >
        <dl>
          <dt>
            {{if this.job.hasChildren "Parent Job" "Job"}}
          </dt>
          <dd>
            {{this.job.trimmedName}}
          </dd>
        </dl>
      </LinkTo>
    </li>
  {{/if}}
</Trigger>